package org.csmzxy.class2334;

import java.time.LocalDate;
import java.util.Locale;

public class Example11 {
    public static void main(String[] args){
        LocalDate now = LocalDate.now();
        LocalDate of = LocalDate.of(2023,11,20);
        System.out.println("当前日期now：" +now);
        System.out.println("当前日期of：" +of);
        System.out.println("1.LocalDate类中的获取方法-------");
        System.out.println("当前的年份：" +now.getYear());
        System.out.println("当前的月份：" +now.getMonthValue());
        System.out.println("当前为本月的第几天：" +now.getDayOfMonth());
        System.out.println("2.LocalDate类中的判断方法-------");
        System.out.println("日期of是否在now之前" +of.isBefore(now));
        System.out.println("日期of是否在now之后：" +of.isAfter(now));
        System.out.println("日期of是否与now相等：" +of.equals(now));
        System.out.println("日期of是否是闰年：" +of.isLeapYear());
        System.out.println("3.LocalDate类中的解析及加减操作方法---");
        String dateStr = "2023-11-11";
        System.out.println("把日期字符解析成日期对象的结果为"+LocalDate.parse(dateStr));
        System.out.println("将now的年份加1后的结果为"+now.plusYears(1));
        System.out.println("将now的天数减10后的结果为"+now.minusDays(10));
        System.out.println("将now的年份设置为2022后的结果为"+now.withYear(2022));
    }
}
